package pattern;

public class Singleton {
    public static  void  main(String []args){

        Student s1=Student.getInstannce();
        Student s2=Student.getInstannce();
        System.out.println(s1==s2);


        Teacher t1=Teacher.getInstannce();
        Teacher t2=Teacher.getInstannce();
        System.out.println(t1==t2);
    }
}

class Student{
    private static Student student=new Student();
    public static Student getInstannce()
    {
        return student;
    }
}

class Teacher{
    private static Teacher teacher=null;
    public synchronized static Teacher getInstannce()
    {
        if (teacher==null)
        {
            teacher=new Teacher();
        }
        return teacher;
    }
}